package com.palfund.ui.recyclerview.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.palfund.ui.R;
import java.util.HashMap;

/**
 * Created by clvc on 2017/10/30.
 * 真正的速度是看不见的 !
 * Today is today , we will go !
 */

public class GridAdapter extends RecyclerViewAdapter<HashMap<String, Object>> {
    public GridAdapter(Context context) {
        super(context);
    }

    @Override
    public RecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.item1_recycleview, parent, false);
        return new GridViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerViewAdapter.RecyclerViewHolder holder, int position) {
        HashMap<String, Object> hashMap = mList.get(position);
        String index = (String) hashMap.get("index");
        Bitmap bitmap = (Bitmap) hashMap.get("image");
        GridViewHolder baseViewHolder = (GridViewHolder) holder;
        baseViewHolder.mTextView.setText(index);
        baseViewHolder.mImageView.setImageBitmap(bitmap);
    }

    class GridViewHolder extends RecyclerViewHolder {
        private ImageView mImageView;
        private TextView mTextView;

        public GridViewHolder(View view) {
            super(view);
            mImageView = (ImageView) itemView.findViewById(R.id.imageView_item1);
            mTextView = (TextView) itemView.findViewById(R.id.textView_item1);
        }
    }
}
